package net.uzen.office.board.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import net.uzen.office.board.model.Board;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class BoardDaoImpl extends SqlMapClientDaoSupport implements BoardDao {

	@Override
	@SuppressWarnings("unchecked")
	public List<Board> getBoardList(Map<String, Object> requestMap) {
		return (ArrayList<Board>) getSqlMapClientTemplate().queryForList(
				"board.getBoardList", requestMap);
	}

	@Override
	public int createBoard(Board board) {
		int boardNo = (Integer) getSqlMapClientTemplate().insert(
				"board.createBoard", board);

		return boardNo;
	}

	@Override
	public boolean modifyBoard(Board board) {
		int result = getSqlMapClientTemplate().update("board.modifyBoard",
				board);
		return result > 0 ? true : false;
	}

	@Override
	public Board getBoard(Board board) {
		return (Board) getSqlMapClientTemplate().queryForObject(
				"board.getBoard", board);
	}

	@Override
	public boolean deleteBoard(int boardNo) {
		int result = getSqlMapClientTemplate().delete("board.deleteBoard",
				boardNo);
		return result > 0 ? true : false;
	}
}
